class Candidate < ActiveRecord::Base

  hobo_model

  has_many :votes, :dependent => :destroy

  belongs_to :election
  
  attr_accessible :name, :description, :election_id

  # --- Validation --- #
  
  validates_presence_of :name, :election
  validates_uniqueness_of :name, :scope => :election_id
  validates_length_of :name, :in => 2..80

  # --- Hobo Permissions --- #

  def creatable_by?(creator)
    false
  end

  def updatable_by?(updater, new)
    false
  end

  def deletable_by?(deleter)
    false
  end

  def viewable_by?(viewer, field)
    viewer.admin?
  end

end
